import os

def PickCheckOutFileName(fileName = 'C:\\liangr\\checkout_franklin.txt'):
    try:        
        with open(fileName, 'r') as fileRead:
            nameList = []
            for line in fileRead:
                startIndex = line.lower().find('checkout version \"')
                if startIndex == -1:
                    continue;
                endIndex = line.lower().find('"', startIndex + len('checkout version \"'))
                if endIndex == -1:
                    nameList.append(line[startIndex + len('checkout version \"'): ])
                else:
                    nameList.append(line[startIndex + len('checkout version \"'): endIndex])
            return nameList
    except IOError:
        print('The file cannot open!' + fileName)


def DoCheckOut(workDir, nameList):
    for everyName in nameList:
        command = 'ct co -unreserved -c \"FIPS 2.0\" ' + workDir + everyName
        os.system(command)

def Fire():
    DoCheckOut(r'Y:\NaviServices', PickCheckOutFileName())
    
